/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - core/memory
// Copyright( c) 2013.  All Rights Reserved
//
// File:		AEMemoryConfig.h
// Author:		Gianluca Belardelli
// Date:		02/01/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AEMEMORYCONFIG_H_
#define _AEMEMORYCONFIG_H_

class AE_COREDLLIMPEXP AEMemoryConfig
{
// Members
protected:
	static AEMemoryConfig *m_lpInstance;

public:
	/// Construction info for hkMemorySystem
	struct AE_COREDLLIMPEXP AEMemoryConfigInfo
	{
		AEUINT32 m_uiMemorySize;
		AEUINT32 m_uiMemoryIncrease;

		AEMemoryConfigInfo( AEUINT32 uiMemorySize, AEUINT32 uiIncrease ) : m_uiMemorySize( uiMemorySize ),
			m_uiMemoryIncrease( uiIncrease ) {};
	};
// Methods
public:
	AE_DECLARE_PLACEMENT_ALLOCATOR();

	virtual ~AEMemoryConfig( void );

	/// Memory system methods.
	/// These are not normal methods of hkMemoryRouter because each instance is
	/// thread local, but the methods operate on the global system.
	/// The code which initializes the memory system will set these pointers
	/// as only it knows how they should be implemented.
	virtual AEMemoryManager *MainInit( const AEMemoryConfigInfo &mcInfo ) = 0;

	/// Shut down the memory system.
	/// Some implementations will return HK_FAILURE if leaks are detected.
	virtual AERESULT MainQuit( void ) = 0;

	/// Method for threads to construct their local instances.
	virtual void ThreadMemInit( AEMemoryManager &refMemMgr, const char *lpName ) = 0;
	/// Method for threads to deinitialize their local instances.
	virtual void ThreadMemQuit( AEMemoryManager &refMemMgr ) = 0;

	/// Get the global instance
	static AEMemoryConfig& AE_CALL GetInstance( void );

	/// Get the global instance pointer
	static AEMemoryConfig* AE_CALL GetInstancePtr( void );

	static void AE_CALL ReplaceInstance( AEMemoryConfig *lpPtr );
};

#endif // _AEMEMORYCONFIG_H_
